package listbyorder.access801_900.test836;

/**
 * @author code_yc
 * @version 1.0
 * @date 2020/8/3 19:43
 */
public class Solution1 {

    public boolean isRectangleOverlap(int[] rec1, int[] rec2) {
        int[] x1 = {rec1[0], rec1[2]};
        int[] y1 = {rec1[1], rec1[3]};
        int[] x2 = {rec2[0], rec2[2]};
        int[] y2 = {rec2[1], rec2[3]};
        return isContians(x1, x2) && isContians(y1, y2);
    }

    private boolean isContians(int[] arr1, int[] arr2) {
        if (arr1[0] == arr2[0] || arr1[1] == arr2[1]) return true;
        if (arr1[0] > arr2[0]) {
            return arr1[0] < arr2[1];
        } else {
            return arr2[0] < arr1[1];
        }
    }
}
